#    Tichy
#
#    copyright 2008 Guillaume Chereau (charlie137@gmail.com)
#
#    This file is part of Tichy.
#
#    Tichy is free software: you can redistribute it and/or modify it
#    under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    Tichy is distributed in the hope that it will be useful, but
#    WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
#    General Public License for more details.
#
#    You should have received a copy of the GNU General Public License

import os


def get_resource(path):
    if path.startswith(':/'):
        path = path[2:]
    dirs = ['../res', 'res', '/usr/share/tichy/res', '/usr/tichy/res']
    for dir_ in dirs:
        full_path = os.path.join(dir_, path)
        if os.path.exists(full_path):
            return full_path
    raise IOError("can't find resource '%s'" % path)
